package com.chihihx.launcher.ui.fragment

import androidx.recyclerview.widget.LinearLayoutManager
import com.chihihx.launcher.BaseWallPaperFragment
import com.chihihx.launcher.bean.NetSettingDto
import com.nova.android.tvlauncher.R
import com.nova.android.tvlauncher.constants.ConstantsAtv.PACKAGE_NAME_MAIN_SETTING
import com.nova.android.tvlauncher.constants.ConstantsAtv.PACKAGE_NAME_WIFI_SETTING
import com.nova.android.tvlauncher.databinding.FragmentWifiSettingHxtvBinding
import com.nova.android.tvlauncher.databinding.ItemNetInfoBinding
import com.nova.android.tvlauncher.ext.clickNoRepeatWithAnim
import com_github_lib_base.base.BaseViewModel
import com_github_lib_base.ext.openApp
import com_github_lib_base.ext.rv.addModels
import com_github_lib_base.ext.rv.setup

class WifiSettingFragment: BaseWallPaperFragment<FragmentWifiSettingHxtvBinding, BaseViewModel>() {
    override fun initView() {
        mBind.rvNetinfo.layoutManager = LinearLayoutManager(requireContext())
        mBind.rvNetinfo.setup(mutableListOf()) {
            addType(NetSettingDto::class, R.layout.item_net_info)
            onBind {
                val itemBinding = getBinding<ItemNetInfoBinding>()
                val item = getModel<NetSettingDto>()
                itemBinding.tvTitle.text = item.title
                itemBinding.tvContent.text = item.content
            }
        }

        mBind.rvNetSetting.setup(mutableListOf()) {
            addType(NetSettingDto::class, R.layout.item_net_setting)
            onBind {
                val itemBinding = getBinding<ItemNetInfoBinding>()
                val item = getModel<NetSettingDto>()
                itemBinding.tvTitle.text = item.title
                itemBinding.tvContent.text = item.content
                itemBinding.root.clickNoRepeatWithAnim {
                    when(item.eventType){
                        "wifi"->{
                            PACKAGE_NAME_WIFI_SETTING.openApp()
                        }
                        "ethernet"->{}
                    }
                }
            }
        }

        val ipAdress = "192.168.0.1"
        val netInfoList = mutableListOf<NetSettingDto>().apply {
            add(NetSettingDto("网络名称","WIFI-5G"))
            add(NetSettingDto("连接方式","WIFI"))
            add(NetSettingDto("IP 地址","WIFI"))
            add(NetSettingDto("信号强度","99/100"))
            add(NetSettingDto("默认网关","99/100"))
            add(NetSettingDto("Mac地址","99/100"))
        }

        val netSettingList = mutableListOf<NetSettingDto>().apply {
            add(NetSettingDto("无线网络","WIFI-5G","wifi"))
            add(NetSettingDto("有线网络","未连接到以太网","ethernet"))

        }
        mBind.rvNetinfo.addModels(netInfoList)
        mBind.rvNetSetting.addModels(netSettingList)
    }
}